import java.util.*;
/**
 * 区别开-穷举的方式创建二叉树
 * Created with IntelliJ IDEA.
 * User:xieChao
 * Date:2022/10/8 15:14
 */

class BinaryTree {
    public char val;
    public BinaryTree left;
    public BinaryTree right;

    public BinaryTree(char val) {
        this.val = val;
    }
}

public class Main{
    public static int i = 0;
    public static   BinaryTree create(String str){
        BinaryTree root = null;
        if(str.charAt(i) != '#'){
            root = new BinaryTree(str.charAt(i));
            i++;
            root.left = create(str);
            root.right = create(str);
        }else{
            //遇到#就是空树
            i++;
        }
        return root;
    }

    /**
     * 中序遍历
     * @param root
     */
    public static void inorder(BinaryTree root){
        if(root == null){
            return;
        }
        inorder(root.left);
        System.out.print(root.val+" ");
        inorder(root.right);
    }


    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextLine()){
            String str = in.nextLine();
            BinaryTree root = create(str);
            inorder(root);
        }
    }
}

